package org.abc.fund.entity.factorEntity;


import com.fasterxml.jackson.annotation.JsonBackReference;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 风格因子组件实体类
 */
@Entity
@Table(name = "style_factor_components")
@Data
@EqualsAndHashCode(callSuper = false)
public class StyleFactorComponent {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 风格因子
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "style_factor", nullable = false)
    @JsonBackReference("styleFactor-components")
    private StyleFactor styleFactor;
    /**
     * 输入因子
     */
    @Column(name = "input_factor_id", nullable = false)
    private String inputFactor;

    /**
     * 权重
     */
    @Column(nullable = false)
    private BigDecimal weight;

    /**
     * 操作类型：MULTIPLY(乘法), ADD(加法), DIVIDE(除法), SUBTRACT(减法)
     */
    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    private OperationType operationType;

    /**
     * 排序
     */
    @Column
    private Integer sortOrder = 0;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(nullable = false, updatable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(nullable = false)
    private LocalDateTime updateTime;

    // ========== 补全getter/setter ==========
    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }
    public StyleFactor getStyleFactor() { return styleFactor; }
    public void setStyleFactor(StyleFactor styleFactor) { this.styleFactor = styleFactor; }
    public String getInputFactor() { return inputFactor; }
    public void setInputFactor(String inputFactor) { this.inputFactor = inputFactor; }
    public BigDecimal getWeight() { return weight; }
    public void setWeight(BigDecimal weight) { this.weight = weight; }
    public OperationType getOperationType() { return operationType; }
    public void setOperationType(OperationType operationType) { this.operationType = operationType; }
    public Integer getSortOrder() { return sortOrder; }
    public void setSortOrder(Integer sortOrder) { this.sortOrder = sortOrder; }
    public LocalDateTime getCreateTime() { return createTime; }
    public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; }
    public LocalDateTime getUpdateTime() { return updateTime; }
    public void setUpdateTime(LocalDateTime updateTime) { this.updateTime = updateTime; }
}